package CreationModel.PrototypeModel.DeepAndShallowClone.DeepCloneOne;

/**
 * @author 王蕾 [wanglei_dev@cyou-inc.com]
 * @date 2017-12-06 17:30:00
 */
public class Swallow implements Cloneable{

    private String name;

    private Wing leftWing;
    private Wing rightWing;

    public Swallow(String name, Wing leftWing, Wing rightWing) {
        this.name = name;
        this.leftWing = leftWing;
        this.rightWing = rightWing;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Wing getLeftWing() {
        return leftWing;
    }

    public void setLeftWing(Wing leftWing) {
        this.leftWing = leftWing;
    }

    public Wing getRightWing() {
        return rightWing;
    }

    public void setRightWing(Wing rightWing) {
        this.rightWing = rightWing;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Swallow swallow = (Swallow) super.clone();

        Wing leftWing = (Wing)swallow.getLeftWing().clone();
        Wing rightWing = (Wing)swallow.getRightWing().clone();

        swallow.setLeftWing(leftWing);
        swallow.setRightWing(rightWing);
        return swallow;

    }
}
